package com.erp.framework.domain;

import com.erp.framework.annotation.Excel;
import com.erp.framework.constant.ConfigConstants;
import com.erp.framework.constant.Constants;
import com.erp.framework.core.domain.BaseEntity;

import javax.validation.constraints.Email;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @author erp
 */
public class SysUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 用户名称
     */
    @Excel(name = "用户名")
    private String userName;

    @Excel(name = "用户类型")
    private String type;

    /**
     * 用户邮箱
     */
    @Excel(name = "用户邮箱")
    private String email;

    /**
     * 密码
     */
    private String password;

    /**
     * 盐加密
     */
    private String salt;

    /**
     * 帐号状态
     */
    @Excel(name = "帐号状态")
    private String status;


    private List<SysRole> roles;

    /**
     * 角色组
     */
    private String[] roleIds;

    /**
     * 组织组
     */
    private String[] postIds;

    /**
     * 部门组
     */
    private String deptId;

    /**
     * 部门名称
     */
    private String deptName;

    /**
     * 角色组名称
     */
    private String roleNames;

    /**
     * 手机号码
     */
    private String phoneNumber;

    /**
     * 部门对象
     */
    private SysDept dept;

    /**
     * 点击判断是否被选中
     */
    private boolean flag = false;

    public SysUser(String userId) {
        this.setId(userId);
    }


    public boolean typeFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public SysUser() {
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public boolean isAdmin() {
        return ConfigConstants.ADMIN_USER_ID.equals(this.getId());
    }

    public static boolean isAdmin(String userId) {
        return ConfigConstants.ADMIN_USER_ID.equals(userId);
    }

    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public String[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String[] roleIds) {
        this.roleIds = roleIds;
    }

    public String[] getPostIds() {
        return postIds;
    }

    public void setPostIds(String[] postIds) {
        this.postIds = postIds;
    }

    public String getRoleNames() {
        return roleNames;
    }

    public void setRoleNames(String roleNames) {
        this.roleNames = roleNames;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
}
